interface IB {
  // sayHi: {
  //   (msg: string) : void
  // }

  // sayHi(x: string): void;

  sayHi: (x: string) => void;
}

let obj: IB = {
  sayHi: function (msg: string) {
    console.log(msg);

  }
}

obj.sayHi('sdfsdf')



interface IPerson {
  username: string
  age?: number
  // 定义任意属性，已经确定的类型必须是下面任意类型的子类型
  [prop: string]: string | number | undefined
}

let zhangsan: IPerson = {
  username: 'zhangsan',
  age: 19,
  father: 'zhangzhang',
  mother: 'wangwu'
}

// 接口定义数组
interface IArr {
  [prop: number]: string
}

let arr1: IArr = ['hellow', 'world']

interface IList {
  username: string,
  age: number,
}

let arrObj: IList[] = [{ username: 'hello', age: 18 }]




